package com.heima.comment.controller;

import com.heima.comment.service.CommentService;
import com.heima.model.comment.dto.CommentDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @projectName: leadnews-project
 * @package: com.heima.comment.controller.v1
 * @className: CommentController
 * @author: Eric
 * @description: TODO
 * @date: 2024/1/25 19:25
 * @version: 1.0
 */
@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 按文章ID查找
     * 负荷
     *
     * @param commentDto 备注dto
     * @return {@link ResponseResult}<{@link ?}>
     */
    @PostMapping("/load")
    public ResponseResult<?> findByArticleId(@RequestBody CommentDto commentDto){
        return commentService.findByArticleId(commentDto);
    }

    /**
     * 点赞
     *
     * @param dto DTO
     * @return {@link ResponseResult}
     */
    @PostMapping("/like")
    public ResponseResult<?> like(@RequestBody CommentDto dto){
        return commentService.like(dto);
    }

    /**
     * 保存评论
     *
     * @param dto DTO
     * @return {@link ResponseResult}<{@link ?}>
     */
    @PostMapping("/save")
    public ResponseResult<?> saveComment(@RequestBody CommentDto dto){
        return commentService.saveComment(dto);
    }


}
